Repository navigation
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
ranm-msft
left a comment
There was a problem hiding this comment.
One ask inline: reconcile custom-content forwarding with the newly added regression test.
| void SetModulePath(Execution::Context& context, IConfigurationSetProcessorFactory const& factory) | ||
| { | ||
| // Ignore settings as the server will retrieve the effective module path from the settings file if needed. | ||
| if (!context.Args.Contains(Execution::Args::Type::ConfigurationModulePath)) |
There was a problem hiding this comment.
This unconditional return appears inconsistent with the new ConfigurationModulePath_CustomContentForwarded test. With no module-path argument, both generated cases return here before Location is set, so REQUIRE(factory->LocationSet) cannot pass. Should this gate distinguish file-backed settings from authoritative custom content, or should the stated contract and test be revised?
ranm-msft
left a comment
There was a problem hiding this comment.
Please address the implicit module-root case and rerun the new null-location test.
| processorEnvironment.PrependPSModulePath(wingetModulePath); | ||
| // Always add the context-specific winget path. | ||
| processorEnvironment.PrependPSModulePath(defaultModulePath); | ||
| if (this.Location == PowerShellConfigurationProcessorLocation.WinGetModulePath) |
There was a problem hiding this comment.
Correction: Default is an alias of WinGetModulePath, so this branch does use effectiveModulePath. My earlier concern here was incorrect, and I am withdrawing it.
There was a problem hiding this comment.
Default and WinGetModulePath are aliases for the same enum value.
ranm-msft
left a comment
There was a problem hiding this comment.
The x86 build is blocked by signed/unsigned mismatches in the new settings assertions.
ranm-msft
left a comment
There was a problem hiding this comment.
One policy-precedence issue to address before sign-off.
There was a problem hiding this comment.
🟡 Changes recommended
Elevated, unpackaged PowerShell reads a different settings file than Set-WinGetUserSetting -Admin writes, causing the configured default module root to be ignored.
1 open issue
What changed in this PR
Introduces protected, per-user administrator settings so selected ordinary settings cannot control elevated WinGet operations, with management support across the CLI, PowerShell, and DSC.
Changes:
- Adds settings-source precedence, token-specific restrictions, explicit-null defaults, recovery, and warnings.
- Adds administrator-file targeting to settings commands, exports, PowerShell cmdlets, and DSC resources.
- Separates elevated configuration module storage and discovery, with supporting tests, packaging, schemas, and documentation.
| File | Description |
|---|---|
templates/jobs-build.yml |
Packages the native module-path dependency. |
src/WindowsPackageManager/WindowsPackageManager.h |
Declares the native module-path export. |
src/WindowsPackageManager/Source.def |
Exports the module-path function. |
src/WindowsPackageManager/main.cpp |
Resolves module paths using local settings and token context. |
src/PowerShell/tests/Microsoft.WinGet.DSC.Tests.ps1 |
Tests protected DSC target selection. |
src/PowerShell/tests/Microsoft.WinGet.Client.Tests.ps1 |
Tests protected-file management and repair. |
src/PowerShell/scripts/Initialize-LocalWinGetModules.ps1 |
Stages the additional native dependency locally. |
src/PowerShell/Microsoft.WinGet.DSC/Microsoft.WinGet.DSC.psm1 |
Adds administrator-file targeting to the resource. |
src/PowerShell/Microsoft.WinGet.Configuration.Engine/Helpers/OpenConfigurationParameters.cs |
Tracks explicit module-path selection. |
src/PowerShell/Microsoft.WinGet.Configuration.Engine/Commands/ConfigurationCommand.cs |
Leaves implicit module paths for processor resolution. |
src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/UserSettingsCommand.cs |
Routes protected reads and elevated writes. |
src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/TestUserSettingCmdlet.cs |
Adds the -Admin comparison switch. |
src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/SetUserSettingCmdlet.cs |
Adds the -Admin write switch. |
src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Cmdlets/GetUserSettingCmdlet.cs |
Adds the -Admin read switch. |
src/PowerShell/Help/Microsoft.WinGet.DSC/WinGetUserSettings.md |
Documents protected targeting and update semantics. |
src/PowerShell/Help/Microsoft.WinGet.Client/Test-WinGetUserSetting.md |
Documents protected-file comparisons. |
src/PowerShell/Help/Microsoft.WinGet.Client/Set-WinGetUserSetting.md |
Documents elevated writes and explicit nulls. |
src/PowerShell/Help/Microsoft.WinGet.Client/Get-WinGetUserSetting.md |
Documents protected-file reads. |
src/PowerShell/Help/Microsoft.WinGet.Client/Get-WinGetSetting.md |
Documents administrator-file path discovery. |
src/Microsoft.Management.Deployment.InProc/dllmain.cpp |
Adds annotations to COM exports. |
src/Microsoft.Management.Configuration.UnitTests/Tests/ProcessorEnvironmentTests.cs |
Tests deferred imports and module-path cleanup. |
src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs |
Reorders a using alias; no behavior change. |
src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorFactoryTests.cs |
Tests context-specific roots and explicit-path preservation. |
src/Microsoft.Management.Configuration.UnitTests/Microsoft.Management.Configuration.UnitTests.csproj |
Includes the native dependency in tests. |
src/Microsoft.Management.Configuration.UnitTests/Fixtures/UnitTestFixture.cs |
Adapts fixtures to deferred DSC imports. |
src/Microsoft.Management.Configuration.Processor/Public/PowerShellConfigurationSetProcessorFactory.cs |
Resolves local roots and configures discovery paths. |
src/Microsoft.Management.Configuration.Processor/PowerShell/ProcessorEnvironments/ProcessorEnvironmentFactory.cs |
Uses CreateDefault2 without eager DSC imports. |
src/Microsoft.Management.Configuration.Processor/PowerShell/ProcessorEnvironments/HostedEnvironment.cs |
Normalizes module-path cleanup and diagnoses invalid entries. |
src/AppInstallerSharedLib/Public/winget/Resources.h |
Declares additional settings-warning resources. |
src/AppInstallerCommonCore/UserSettings.cpp |
Implements protected overrides, recovery, and file preparation. |
src/AppInstallerCommonCore/Settings.cpp |
Adds administrator-only file mutations. |
src/AppInstallerCommonCore/Runtime.cpp |
Adds protected configuration module defaults. |
src/AppInstallerCommonCore/Public/winget/UserSettings.h |
Classifies settings and extends warning metadata. |
src/AppInstallerCommonCore/Public/winget/Settings.h |
Defines protected primary and backup streams. |
src/AppInstallerCommonCore/Public/AppInstallerRuntime.h |
Declares the context-specific default module path. |
src/AppInstallerCommonCore/pch.h |
Adds the exception header. |
src/AppInstallerCLITests/WorkFlow.cpp |
Tests CLI targeting, warnings, exports, and DSC operations. |
src/AppInstallerCLITests/UserSettings.cpp |
Tests precedence, nulls, recovery, and policy behavior. |
src/AppInstallerCLITests/TestSettings.h |
Extends settings fixtures for custom content. |
src/AppInstallerCLITests/TestSettings.cpp |
Cleans protected settings files between tests. |
src/AppInstallerCLITests/Settings.cpp |
Tests protected storage and mutation permissions. |
src/AppInstallerCLITests/Runtime.cpp |
Tests module defaults and protected directory permissions. |
src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw |
Adds management help and source-specific warnings. |
src/AppInstallerCLICore/Workflows/SettingsFlow.h |
Declares warning and protected-file workflows. |
src/AppInstallerCLICore/Workflows/SettingsFlow.cpp |
Implements protected opening, creation, and path export. |
src/AppInstallerCLICore/Resources.h |
Declares management and DSC resource strings. |
src/AppInstallerCLICore/ExecutionArgs.h |
Adds administrator-file and creation argument types. |
src/AppInstallerCLICore/ConfigurationDynamicRuntimeFactory.cpp |
Preserves explicit versus implicit module defaults. |
src/AppInstallerCLICore/ConfigurationCommon.cpp |
Defers implicit module-path selection to the receiver. |
src/AppInstallerCLICore/Commands/SettingsCommand.cpp |
Adds and validates protected-file command options. |
src/AppInstallerCLICore/Commands/DscUserSettingsFileResource.cpp |
Supports protected DSC targets and authorized writes. |
src/AppInstallerCLICore/Command.cpp |
Reports migration warnings through shared command handling. |
src/AppInstallerCLICore/Argument.cpp |
Maps the --admin and --create arguments. |
schemas/JSON/settings/settings.schema.0.2.json |
Allows null values and documents restricted settings. |
schemas/JSON/settings/settings.export.schema.0.1.json |
Adds the administrator settings-file path. |
doc/specs/Protected Settings Overlay.md |
Describes the design, boundaries, and validation plan. |
doc/Settings.md |
Explains administrator configuration and migration behavior. |
doc/release-notes/1.31/protected-settings-overlay.md |
Announces protected settings and module-storage changes. |
.github/actions/spelling/allow.txt |
Allows terminology introduced by the documentation. |
Review effort: Balanced
ranm-msft
left a comment
There was a problem hiding this comment.
One concrete follow-up from the current diff.
ranm-msft
left a comment
There was a problem hiding this comment.
Thanks for clarifying. I withdraw my implicit-root branch concern: Default aliases WinGetModulePath, so ConfigureModulePaths applies the resolved effective root. The renamed custom-content test now asserts the current no-forwarding behavior rather than the former LocationSet expectation. This is not sign-off: required CI is still failing, and I am awaiting focused owner review of the protected-settings/module-path boundary.
ranm-msft
left a comment
There was a problem hiding this comment.
One administrator-write initialization concern below; otherwise the policy precedence and environment-path follow-ups look addressed. I am leaving approval pending this fix and focused owner review.
|
Copilot Fix the code for all comments in this review thread. When a review comment includes a suggested change, apply the suggestion exactly. Do not make changes beyond what is described in the linked review thread. |
| var settingsJson = orderedSettings.ToString(Formatting.Indented); | ||
| if (this.admin && !File.Exists(this.settingsFilePath)) | ||
| { | ||
| var result = new WingetCLIWrapper().RunCommand( |
ranm-msft
left a comment
There was a problem hiding this comment.
One recovery issue to address before approval.
| } | ||
| else | ||
| { | ||
| CreateAdminSettingsFile(); |
There was a problem hiding this comment.
When the protected primary is missing but its backup is valid, loading selects Backup, so this branch creates an empty primary before opening the editor. The next invocation now prefers that valid empty file over the recovered overrides, even if the administrator makes no edit. Please preserve the recovered backup when preparing the primary, and cover the missing-primary/valid-backup case.

📖 Description
Add a protected, per-user administrator settings file so selected settings from the ordinary, user-writable file cannot control elevated operations. The new
admin-settings.jsonuses the existing settings schema and protected storage, separate from the existing administrator capability controls.nullselects the default. Invalid protected values do not fall back to ordinary-file values; unrecoverable protected-file load failures warn and leave both files' settings unapplied.winget settings --admin,adminSettingsFilein settings export,-Adminon the user-setting PowerShell cmdlets, and target selection on the PowerShell and native DSC settings-file resources. Protected mutations require elevation; existing files can be opened without elevation. Headless creation supports provisioning without launching an editor.CreateDefault2, and tolerate malformed inherited module-path entries with diagnostics.Existing Group Policy precedence, explicit CLI/API path selections, and authoritative in-process settings content remain unchanged. This does not automatically migrate settings or copy ordinary modules into protected storage, and does not restrict every other PowerShell discovery path.
🔍 Validation
Added or updated native, managed, and PowerShell tests for source/context precedence, null and invalid values, backup recovery, policy behavior, protected storage permissions, management target selection, warnings, explicit module roots, inherited path cleanup, and deferred imports.
Microsoft Reviewers: Open in CodeFlow